<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover" />
    <title>个人资料</title>
    <link rel="stylesheet" href="{{asset('/addons/jquery-weui-build/css/weui.min.css')}}">
    <link rel="stylesheet" href="{{asset('/addons/jquery-weui-build/css/jquery-weui.css')}}">
    <link rel="stylesheet" href="{{asset('/css/system/iconfont.css')}}">
    @if($skinid == 3)
        <link rel="stylesheet" href="/css/system/common.css?v={{time()}}">
        <link rel="stylesheet" href="/css/system/new-colleague.css?v={{time()}}">
    @elseif($skinid == 1)
        <link rel="stylesheet" href="/css/theme-blue/system/common.css">
        <link rel="stylesheet" href="/css/theme-blue/system/new-colleague.css?v={{time()}}">
    @elseif($skinid == 2)
        <link rel="stylesheet" href="/css/theme-pink/system/iconfont-pink.css">
        <link rel="stylesheet" href="/css/theme-pink/system/common.css">
        <link rel="stylesheet" href="/css/theme-pink/system/new-colleague.css?v={{time()}}">
    @endif
</head>
<body ontouchstart>
<div class="mian-container">
    <div class="new-colleague">

        <div class="colleague-header">
            <div class="colleague-top">
                <img src={{"/uploads/images/company-logo/".$user->corpid.".png"}}>
            </div>
            <div style="text-align: center;">
                <h3 class="change-h3" style="display: block;margin-bottom: 0;">{{$user->qw_name}}</h3>
                @foreach($user->role as $ur)
                    <span class="circle-span span-reward">{{$rolearray[$ur]}}</span>
                @endforeach
               {{-- <span class="circle-span span-reward">奖</span>
                <span class="circle-span span-exam">考</span>
                <span class="circle-span span-score">绩</span>  --}}
            </div>
            <div class="colleague-list weui-cells">
               {{-- <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <i class="icon iconfont icon-mima"></i>
                    </div>
                    <div class="weui-cell__hd">
                        <p class="p-length">密码</p>
                    </div>
                    <div class="weui-cell__ft">
                        <input class="weui-input password" name="password" type="text" value='123456' readonly/>
                    </div>
                </div>--}}
                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <i class="icon iconfont icon-xingbie"></i>
                    </div>
                    <div class="weui-cell__hd">
                        <p class="p-length">性别</p>
                    </div>
                    <div class="weui-cell__ft ">
                        <input class="weui-input sex" name="sex" readonly="readonly" type="text" value='{{$gender[$user->gender]}}'/>
                        {{--<span class="right-icon"></span>--}}
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <i class="icon iconfont icon-bumen1"></i>
                    </div>
                    <div class="weui-cell__hd">
                        <p class="p-length">部门</p>
                    </div>
                    <div class="weui-cell__ft ">
                        <input name="department" class="weui-input department" type="text" value='{{getGroupName($user->group_id)}}' data-values="{{$user->group_id}}"/>
                        <span class="right-icon"></span>
                    </div>
                </div>
                <div class="weui-cell">
                    <div class="weui-cell__hd">
                        <i class="icon iconfont icon-zhiwei"></i>
                    </div>
                    <div class="weui-cell__hd">
                        <p class="p-length">职位</p>
                    </div>
                    <div class="weui-cell__ft ">
                        <input class="weui-input position" name="position" type="text" @if($user->is_leader == 1) value='组长' @else value='组员' @endif  data-values="{{$user->is_leader}}"/>
                        <span class="right-icon"></span>
                    </div>
                </div>
            </div>
        </div>
        <div class="a-link">
            <button class="weui-btn weui-btn_color save-info">保存</button>
            <a href="javascript:;" class="weui-btn weui-btn_warn delete-colleague">删除同事</a>
        </div>
           {!! csrf_field() !!}
           <input type="hidden" name="userid" value="{{$user->id}}">

    </div>
</div>
<div class="list-shadow"></div>
<script src="{{asset('/kaohe/js/jquery-2.1.4.min.js')}}"></script>
<script src="{{asset('/addons/jquery-weui-build/js/fastclick.js')}}"></script>
<script>
    $(function() {
        document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
        FastClick.attach(document.body);
    });
</script>
<script src="{{asset('/addons/jquery-weui-build/js/jquery-weui.min.js')}}"></script>
<script>
  $(document).ready(function (){
    // 底部弹出选择
    /*$(".sex").picker({
          title: "请选择性别",
          cols: [
            {
              textAlign: 'center',
              values: ['男', '女']
            }
          ]
    });*/
   /* $(".department").picker({
          title: "选择部门",
          cols: [
            {
              textAlign: 'center',
              values: ['行政部', '企划部','销售部','开发部','设计部','财务部','人事部','后勤部'],
            }
          ]
    });*/

      var ddd = {!! $groups !!};
      $(".department").select({
          title: "选择部门",
          items: ddd,
          onOpen:function () {
            $('.list-shadow').css('display','block');
          },
          onClose:function () {
              $('.list-shadow').css('display','none');
          }
      });

      $(".position").select({
          title: "选择职位",
          items: [{
              'title':'组长',
              'value':'1',
          },{
              'title':'组员',
              'value':'0',
          }],
          onOpen:function () {
              $('.list-shadow').css('display','block');
          },
          onClose:function () {
              $('.list-shadow').css('display','none');
          }
      });
    /*$(".position").picker({
          title: "选择职位",
          cols: [
            {
              textAlign: 'center',
              values: ['组长','组员']
            }
          ]
    });*/
    //删除同事
    $('.delete-colleague').click(function(){
        $.confirm({
          title: '删除',
          text: '确认将同事'+$('.change-h3').text()+'删除，并解除同事关系！',
          onOK: function () {
            //点击确认
              var userid = $('input[name=userid]').val();
              var token = $('input[name=_token]').val();
              $.ajax({
                  'url': '/sysadmin/user/del-user?_token='+token+'&userid='+userid,
                  'type': 'POST',
                  'data': '',
                  error: function (request) {
                      $.toast('网络错误',"text");
                  },
                  success: function (data) {
                      if (data.status == 'success') {
                          $.toast("操作成功");
                          setTimeout(function(){ window.location.href='/sysadmin/permission/index' }, 1000);
                      } else {
                          $.toast(data.msg,"text");
                      }
                  },
              });
          },
          onCancel: function () {
          }
        });
    });

      $('.save-info').click(function(){
         var dep = $('input[name=department]').attr('data-values');
          var leader = $('input[name=position]').attr('data-values');
          var userid = $('input[name=userid]').val();
          var token = $('input[name=_token]').val();
          $.ajax({
              'url': '/sysadmin/user/modify-user?_token='+token+'&userid='+userid,
              'type': 'POST',
              'data': '&is_leader='+leader+'&groupid='+dep,
              error: function (request) {
                  console.log("error");
              },
              success: function (data) {
                  if (data.status == 'success') {
                      $.toast("操作成功");
                      setTimeout(function(){ window.location.href='/sysadmin/permission/index' }, 1000);
                  } else {
                      console.log("error");
                  }
              },
          });
      });


  })
</script>
</body>
</html>
